﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CodeGeneratorBootstrap.Models;

namespace CodeGeneratorBootstrap.Template.Web.Mapper
{
    public partial class CalendarBSearchMapper : ITemplate
    {
        public MetaData Data { get; set; }
        public List<LookupClassModel> lookups { get; set; }
        public List<PickupListModel> pickuplist { get; set; }

        public string Filename
        {
            get { return "CalendarBSearchMapper.cs"; }
        }
        public string FolderName
        {
            get { return ""; }
        }

        public bool IsGenerateOneTime { get { return true; } }
        public bool IsGenerateFolder { get { return false; } }
        public bool IsRequiredOnlyOneMember { get { return true; } }
        public GenerateStyle GenerateStyle { get { return GenerateStyle.Normal; } }

        public List<ClassModel> DistinctClass()
        {
            var result = new List<ClassModel>();
            if (Data.EventMappers != null)
            {
                foreach (var c in Data.EventMappers)
                {
                    var tmp = result.FindAll(x => x.Id == c.ClassModel.Id);
                    if (tmp.Count == 0)
                    {
                        result.Add(c.ClassModel);
                    }
                }
            }
            return result;
        }
    }
}
